
#include "CFont.h"

TTF_Font* Font;

CFont::CFont() {
}

TTF_Font* CFont::OnLoad(char* File, int Size) {
	TTF_Font* Font_Temp = NULL;

	if((Font_Temp = TTF_OpenFont(File, Size)) == NULL) {
		return NULL;
	}

	return Font_Temp;
}

bool CFont::OnDraw(TTF_Font* Font, int color, char* Text, SDL_Surface* Surf_Src, int X, int Y) {
    if(Font == NULL || Surf_Src == NULL) {
		return false;
	}

    SDL_Color Fore_Color;
	switch (color) {
        case 0:
            Fore_Color = { 0, 0, 0 };
        break;

        case 1:
            Fore_Color = { 255, 255, 255 };
        break;

        case 2:
            Fore_Color = {255, 0, 110};
        break;

        default: break;
    }

    SDL_Surface* textSurface = TTF_RenderText_Blended(Font, Text, Fore_Color);
    SDL_Rect textLocation = { X, Y, 0, 0 };
    SDL_BlitSurface(textSurface, NULL, Surf_Src, &textLocation);

    return true;
}

bool CFont::OnDraw(TTF_Font* Font, int color, int Text, SDL_Surface* Surf_Src, int X, int Y) {
    if(Font == NULL || Surf_Src == NULL) {
		return false;
	}

    char str[11];
    sprintf(str, "%d", Text);

    SDL_Color Fore_Color;
    switch (color) {
        case 0:
            Fore_Color = { 0, 0, 0 };
        break;

        case 1:
            Fore_Color = { 255, 255, 255 };
        break;

        case 2:
            Fore_Color = {255, 0, 0};
        break;

        default: break;
    }

    SDL_Surface* textSurface = TTF_RenderText_Blended(Font, str, Fore_Color);
    SDL_Rect textLocation = { X, Y, 0, 0 };
    SDL_BlitSurface(textSurface, NULL, Surf_Src, &textLocation);

    return true;
}
